<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生完成情况 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            padding-top: 20px;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .status-badge {
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: bold;
        }
        .status-submitted {
            background-color: #f0ad4e;
            color: white;
        }
        .status-graded {
            background-color: #5cb85c;
            color: white;
        }
        .status-not-started {
            background-color: #d9534f;
            color: white;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <i class="fa fa-users"></i> 班级：<span th:text="${clazz?.className}"></span> - 
                    作业：<span th:text="${assignment?.title}"></span>
                </h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <a th:href="@{/class/students(id=${clazz.id})}" class="btn btn-default" style="margin-bottom: 20px;">
                    <i class="fa fa-arrow-left"></i> 返回作业列表
                </a>
                
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>学号</th>
                            <th>姓名</th>
                            <th>完成状态</th>
                            <th>提交时间</th>
                            <th>分数</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:if="${#lists.isEmpty(statusList)}">
                            <td colspan="6" class="text-center">该班级暂无学生</td>
                        </tr>
                        <tr th:each="status : ${statusList}">
                            <td th:text="${status.student?.studentNumber}"></td>
                            <td th:text="${status.student?.name}"></td>
                            <td>
                                <span th:if="${status.status == '已批改'}" class="status-badge status-graded">已批改</span>
                                <span th:if="${status.status == '已提交'}" class="status-badge status-submitted">已提交</span>
                                <span th:if="${status.status == '未答题'}" class="status-badge status-not-started">未答题</span>
                            </td>
                            <td th:text="${status.submission?.submitTime != null ? #dates.format(status.submission.submitTime, 'yyyy-MM-dd HH:mm') : '-'}"></td>
                            <td>
                                <span th:if="${status.submission?.score != null}" th:text="${status.submission.score + '分'}"></span>
                                <span th:if="${status.submission?.score == null}">-</span>
                            </td>
                            <td>
                                <a th:if="${status.submission != null}" 
                                   th:href="@{/assignment/grade(submissionId=${status.submission.id})}" 
                                   class="btn btn-sm btn-primary">
                                    <i class="fa fa-edit"></i> 批改
                                </a>
                                <span th:if="${status.submission == null}" class="text-muted">-</span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>

